* oilwork-regress.do
* Performs regression analysis for "Fossil fuel employment" 
* Endre Tvinnereim, Elisabeth Ivarsflaten
set scheme s1mono
cd O:\2.0-NCP\data4
use w01_P* w01_k2 w01_k3 w01_k20 w01_k24 w01_k25_1 w01_k1  w01_k15_99 /// background/generic
   w02_k208-w02_km253 w02_km* w03_r3dvh_1 w01_k31_3 w02_k205ac_3 w03_r3k31_3 ///
   w03_r3k2* w01_W* w03_P*  /// background r3
   w01_km* w01_km* w03_km* w03_r3km* r4km* w01_dt10_7 ///
   w03_qw1* w03_r3km19 w02_km223abc_1 w03_r3k3_2 /// 
   w01_Weight2 w03_Weight_1 w03_Weight_2 r4_Weight* ///
   using "NMP - NO - w01-w04.dta", clear
cd O:\2.21-oilwork\data

*** Recodes, labeling etc. ***
* Dependent variables * 

*1 Tax breaks/incentives for the oil industry
gen oiltax1=w01_km13_5 /* "redusere skattefordeler" */
replace oiltax1=. if w01_km13_5>95
replace oiltax1=(7-oiltax1)/6
label var oiltax1 "Reduce tax incentives for oil exploration R1" 

gen oiltax2=w01_km13_6 /* "skjerpe skattereglene"  */
replace oiltax2=. if w01_km13_6>95
replace oiltax2=(7-oiltax2)/6
label var oiltax2 "Tighten tax regulations for oil exploration R1" 
* ttest oiltax1=oiltax2, unpaired
* Overall measure
gen oiltax0=.
replace oiltax0=oiltax1 if oiltax1!=.
replace oiltax0=oiltax2 if oiltax2!=.
tab oiltax0 w01_km13_5, mi
tab oiltax0 w01_km13_6, mi
**creating a dummy for each experimental manipulation 
gen expoiltaxincent=.
replace expoiltaxincent=1 if oiltax1!=.
replace expoiltaxincent=0 if oiltax2!=.
label var expoiltaxincent "Oil tax framed as less tax incentive not more tax"
tab w01_km13_5 expoiltaxincent, mi
tab w01_km13_6 expoiltaxincent, mi

*2 w03_r3dvh_1: Statement: We should not allow oil and gas extraction in the area by Lofoten and Vester步n.
recode w03_r3dvh_1 (97 98=.), gen(lofnooilR3)
replace lofnooilR3=(7-lofnooilR3)/6
label var lofnooilR3 "Should not extract Lofoten oil (W3)"
tab w03_r3dvh_1 lofnooilR3, mi

*3 Reduce oil production
recode w02_km213a (97 98=.), gen (redincoil1)
replace redincoil1=(3-redincoil1)/2
tab w02_km213a redincoil1, mi

recode w02_km213b (97 98=.), gen (redincoil2)
replace redincoil2=(3-redincoil2)/2
tab w02_km213b redincoil2, mi

gen redincoil0=.
replace redincoil0=redincoil1 if redincoil1!=.
replace redincoil0=redincoil2 if redincoil2!=.
tab redincoil0 w02_km213a, mi
tab redincoil0 w02_km213b, mi
gen reducoil=redincoil0
replace reducoil=0 if redincoil0==.5
label var reducoil "Reduce oil production (W2)"
tab w02_km213a reducoil, mi
tab w02_km213b reducoil, mi

* 4 Tighten CO2 emissions permitted, with or without ETS mention
gen tighten1=w01_km13_1
replace tighten1=. if w01_km13_1>=97
replace tighten1=(7-tighten1)/6
tab tighten1 w01_km13_1, nol mi
label variable tighten1 "Tighten rules on CO2 emissions by cutting number of permits"

gen tighten2=w01_km13_2
replace tighten2=. if w01_km13_2>=97
replace tighten2=(7-tighten2)/6
tab tighten2 w01_km13_2, nol mi
label variable tighten2 "Tighten rules on CO2 emissions"
ttest tighten1=tighten2, unpaired

**creating a combined variable signifying degree of agreement that
* emissions should be curbed, with or without ETS
gen tighten0=.
replace tighten0=tighten1 if tighten1!=.
replace tighten0=tighten2 if tighten2!=.
tab w01_km13_1 tighten0, mi
tab w01_km13_2 tighten0, mi
**creating a dummy for each experimental manipulation 
gen etsmentiondummy=.
replace etsmentiondummy=0 if tighten2!=.
replace etsmentiondummy=1 if tighten1!=.
tab w01_km13_1 etsmentiondummy, mi
tab w01_km13_2 etsmentiondummy, mi

* (5) CCS 2013 
* CCS with and without Mongstad
gen ccs1=w01_km13_3
replace ccs1=. if w01_km13_3>95
replace ccs1=(7-ccs1)/6
tab w01_km13_3 ccs1, mi
label var ccs1 "Strengten CCS efforts" 
*
gen ccs2=w01_km13_4
replace ccs2=. if w01_km13_4>95
replace ccs2=(7-ccs2)/6
label var ccs2 "Strengten CCS efforts, cf. Mongstad 'moon landing'"
tab w01_km13_4 ccs2, mi
ttest ccs1=ccs2, unpaired
* Overall R1 2013
gen ccs0=ccs1
replace ccs0=ccs2 if ccs1==.
label var ccs0 "Strengten CCS efforts" 
tab ccs0 ccs1, mi
tab ccs0 ccs2, mi
label var ccs0 "Strengten CCS efforts" 

* (6) Renewables govt support: Offshore wind (round 3) 
recode w03_r3km37_2 (97 98=.), gen(ofshwind)
replace ofshwind=(ofshwind-1)/6
label var ofshwind "Offhore wind: govt support"
tab w03_r3km37_1 ofshwind, mi

* (7) Renewables govt support: Geotherm (round 3)  
recode w03_r3km37_4 (97 98=.), gen(geotherm)
replace geotherm=(geotherm-1)/6
label var geotherm "Geothermal: govt support"
tab w03_r3km37_4 geotherm, mi

***********************************
* Key explanatory variable: work in/near oil/gas or not
recode w01_k24 (1 2=1) (97 98 99 .=.) (else=0), gen(oilwork2)
tab w01_k24 oilwork2, mi
label variable oilwork2 "Work with oil/gas" 
label define oilwork2_label 0 "Not working in oil/gas" 1 "Working in/closely with oil/gas"
label values oilwork2 oilwork2_label
tab w01_k24 oilwork2, mi
gen oilwork2R1=oilwork2

* 3-way: work in or near or not
recode w01_k24 (1=2) (2=1) (97 98 99 .=.) (else=0), gen(oilwork3)
tab w01_k24 oilwork3, mi
label variable oilwork3 "Work with oil/gas, 3-way" 
label define oilwork3_label 0 "Not working in oil/gas" ///
   1 "Working closely with oil/gas" ///
   2 "Working in oil/gas"
label values oilwork3 oilwork3_label
tab w01_k24 oilwork3, mi
gen oilwork3R1=oilwork3

* Again for Round 3
recode w03_r3k24 (1 2=1) (97 98 99 .=.) (3=0), gen(oilwork2R3)
tab w03_r3k24 oilwork2R3, mi
replace oilwork2=oilwork2R3 if oilwork2==.

* ... and 3-way
recode w03_r3k24 (1=2) (2=1) (97 98 99 .=.) (3=0), gen(oilwork3R3)
tab w03_r3k24 oilwork3R3, mi
replace oilwork3=oilwork3R3 if oilwork3==.

********************************
* Control variables


gen age=w01_P5_1
label variable age "Age"
label values age w01_P5_1
tab w01_P5_1 age, mi
replace age=w03_P5_1 if age==.
tab age, mi

gen gender=w01_P1-1
label variable gender "Gender (F=1)"
* label values gender w01_P1
tab w01_P1 gender, mi
replace gender=w03_P1-1 if gender==.
tab gender, mi

gen income=w01_k25_1
label variable income "Income (NOK, annual)"
su income
replace income=w03_r3k25 if income==.
su income
* tab income, mi

* Log income
gen incomeLOG=ln(income+1)
* scatter incomeLOG income

* Generate factor variables, thanks to http://www.stata.com/support/faqs/data-management/creating-dummy-variables/
tabulate age, gen(ageI)
drop ageI1
replace ageI6=1 if ageI7==1
drop ageI7 /* because only 272 resp. in this category: avoid omitting it */ 
label variable ageI6 "age>66"
tab age ageI6, mi 

* Factor: Education
gen edu3=w01_P4
label variable edu3 "Education (3 cat.) 
replace edu3=w03_P4_1 if edu==.
tab edu3, mi

tabulate edu, gen(eduI)
drop eduI1
tab edu3 eduI2
tab edu3 eduI3
tab edu3 eduI4

* Factor: Region
gen region=w01_P2
label variable region "Region" 
replace region=w03_P2 if region==.
tab w01_P2 region, mi
tab w03_P2 region, mi

tabulate region, gen(regionI)
drop regionI1
tab w01_P2 regionI3
tab w03_P2 regionI5


**********************************
* REGRESSION ANALYSES: Table 2. Updated May 2016 (RR)
* We generally use weight2 for either Wave 1 or Wave 3, as these include education and are recommended by I2E. 

* (1) Reduce tax incentives/Tighten tax regulation regarding oilfield exploration
regress oiltax0 oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2 expoiltaxincent [pw=w01_Weight2]
* regress oiltax0 oilwork2 ageI* gender eduI* incomeLOG regionI* expoiltaxincent [pw=w01_Weight2]
estimates store oiltax, title (Oil tax regime)

* (2) Support policy not to consider Lofoten, Vesteraalen, Senja oil next 4 years
regress lofnooilR3 oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store lofnooil, title (Lofoten drilling)

* (3) Reduce (or increase) Norwegian oil production. Wave 2. starts with n=514. 
logit reducoil oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2 [pw=w01_Weight2]
estimates store reducoil, title ("Reduce oil prod (logit)")

* (4) Tighten emissions ceiling / ETS 2013 [diffuse cost]
regress tighten0 oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2 etsmentiondummy [pw=w01_Weight2] 
estimates store tighten, title (Tighten CO2 cap)
* original submission/ here's a difference ::: regress tighten0 oilwork2 age gender edu3 incomeLOG

* (5) CCS 2013 
regress ccs0 oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2  [pw=w01_Weight2]
estimates store ccs, title (CCS)
* CCS Round 2:similar result but lower N: regress ccs0R2 oilwork2 age gender edu3  incomeLOG

* (6) Renewables govt support: Offshore wind (round 3) 
regress ofshwind oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store ofshwind, title (Offshore wind)

* (7) Renewables govt support: Geotherm (round 3) 
regress geotherm oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store geotherm, title (Geothermal)

* Output: Table 2 (main regression table) 
estout oiltax lofnooil reducoil tighten  ofshwind geotherm ccs ///
  using "table2-regressions.txt", replace ///
  cells(b(star fmt(%9.3f)label(Coef.))  t(par label(Std. err.)))  ///
  stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared "N. of cases")) label legend       ///
  varlabels(_cons Constant) posthead("") prefoot("") postfoot("") ///
  style(tab) varwidth(30) 
 
* Unwegithed results: 
regress oiltax0 oilwork2 ageI* gender i.w01_P4 incomeLOG regionI* expoiltaxincent 
regress lofnooilR3 oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 
logit reducoil oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2 
regress tighten0 oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2 etsmentiondummy 
regress ofshwind oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 
regress geotherm oilwork2 ageI* gender i.w03_P4_1 incomeLOG i.w03_P2 
regress ccs0 oilwork2 ageI* gender i.w01_P4 incomeLOG i.w01_P2  
* In sum, no substantial difference. 
 
 
*** APPENDIX ***
*  Estimate models distinguishing between direct and indirect oil/gas sector workers.

recode oilwork3 (0 1=0) (2=1), gen(oilworkdirect)
tab oilwork3 oilworkdirect, mi

recode oilwork3 (0 2=0) (1=1), gen(oilworkindirect)
tab oilwork3 oilworkindirect, mi

* (1) Reduce tax incentives/Tighten tax regulation regarding oilfield exploration
regress oiltax0 oilworkdirect oilworkindirect i.age gender i.w01_P4 incomeLOG i.w01_P2 expoiltaxincent [pw=w01_Weight2]
estimates store oiltax, title (Oil tax regime)
* (2) Support policy not to consider Lofoten, Vesteraalen, Senja oil next 4 years
* choose R3 because much bigger sample
regress lofnooilR3 oilworkdirect oilworkindirect i.age gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store lofnooil, title (Lofoten drilling)
* (3) Reduce (or increase) Norwegian oil production. Wave 2. starts with n=514. 
logit reducoil oilworkdirect oilworkindirect i.age gender i.w01_P4 incomeLOG i.w01_P2 [pw=w01_Weight2]
estimates store reducoil, title ("Reduce oil prod (logit)")
* (4) Tighten emissions ceiling / ETS 2013 [diffuse cost]
regress tighten0 oilworkdirect oilworkindirect i.age gender i.w01_P4 incomeLOG i.w01_P2 etsmentiondummy [pw=w01_Weight2] 
estimates store tighten, title (Tighten CO2 cap)
* original submission/ here's a difference ::: regress tighten0 oilwork2 age gender edu3 incomeLOG
* (5) CCS 2013 
regress ccs0 oilworkdirect oilworkindirect i.age gender i.w01_P4 incomeLOG i.w01_P2  [pw=w01_Weight2]
estimates store ccs, title (CCS)
* CCS Round 2:similar result but lower N: regress ccs0R2 oilwork2 age gender edu3  incomeLOG
* Renewables govt support: Offshore wind (round 3) 
regress ofshwind oilworkdirect oilworkindirect i.age gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store ofshwind, title (Offshore wind)
* Renewables govt support: Geotherm (round 3) 
regress geotherm oilworkdirect oilworkindirect i.age gender i.w03_P4_1 incomeLOG i.w03_P2 [pw=w03_Weight_2]
estimates store geotherm, title (Geothermal)
* Output table 
estout oiltax lofnooil reducoil tighten  ofshwind geotherm ccs ///
  using "appendix-reg-table.txt", replace ///
  cells(b(star fmt(%9.3f)label(Coef.)) t(par label(T-statistic)))  ///
  stats(r2 N, fmt(%9.3f %9.0g) labels (R-squared "N. of cases")) label legend       ///
  varlabels(_cons Constant) posthead("") prefoot("") postfoot("") ///
  style(tab) varwidth(30) 

* Save data set for Clarify
save "oilwork-for-clarify", replace




